package cn.bdqn.witcity.controller;

import cn.bdqn.witcity.entity.Bar;
import cn.bdqn.witcity.entity.Shop;
import cn.bdqn.witcity.entity.User;
import cn.bdqn.witcity.entity.WuYe;
import cn.bdqn.witcity.mapper.PersonMapper;
import cn.bdqn.witcity.service.MenuService;
import cn.bdqn.witcity.service.ShopService;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.List;

@Controller
public class LoginController {
    @Resource
    MenuService menuService;
    @Resource
    ShopService shopService;
    @Resource
    PersonMapper personMapper;

    @RequestMapping("/index")
    public String index(Model model){
        List<Bar> bars=menuService.garAllParentMenuByRole();
        model.addAttribute("bars",bars);
        return "/views/index";
    }
    @RequestMapping("/sys/userList")
    public String userList(){
        return "/views/user/user/list";
    }
    @RequestMapping("/sys/rolemgr")
    public String roleList(){
        return "/views/user/role/list";
    }
    @RequestMapping("/sys/toAddRole")
    public String roAddRole(){
        return "/views/user/role/roleadd";
    }
    @RequestMapping("/shop/productlist")
    public String list(){
        return "/views/user/product/list";
    }
    @RequestMapping("/toAddProduct")
    public String addProduct(Model model){
        List<Shop> shops=shopService.getAll();
        model.addAttribute("shops",shops);
        return "/views/user/product/productadd";
    }
    @RequestMapping("/yezhu/me")
    public String toYeZhu(Authentication authentication,Model model){
        User user=(User)authentication.getPrincipal();
        model.addAttribute("user",user);
        return "/views/user/person";
    }
    @RequestMapping("/sys/pay")
    public String pay(){
        return "/views/user/pay/list";
    }
    @RequestMapping("/yezhu/pay")
    public String yeZhu(){
        return "/views/user/pay/person";
    }
    @RequestMapping("/yezhu/personadd")
    public String personAdd(Model model){
        List<WuYe> wuYeList=personMapper.getAll();
        model.addAttribute("wuYeList",wuYeList);
        return "/views/user/pay/payadd";
    }
    @RequestMapping("/sys/orderlist")
    public String orderList(){
        return "/views/user/order/orderlist";
    }
    @RequestMapping("/yezhu/order")
    public String yuZhuOrder(){
        return "/views/user/order/melist";
    }
}
